/**
 * Created by hjqi on 2016/4/25.
 */

module.controller('UploadFilesController',
        function ($scope, $cookies, $stateParams,$uibModalInstance,storageService,item) {

        $scope.uploadFile = function () {
            var formData = new FormData(angular.element(document.querySelector("#frmUploadFile"))[0]);
            storageService.uploadfile(item.name,formData).then(function(ret){
                if(ret.data.ret === true){
                    alertify.success("upload success");
                    $uibModalInstance.close(ret.data.filename);
                }
                else{
                    alertify.error("upload success");
                    $uibModalInstance.close();
                }
            },function(e){

            });

            //TODO create pvc

        }

        $scope.cancel = function(){
            $uibModalInstance.dismiss('cancel');
        };


    }
);